package com.tmeone.erpone.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tmeone.erpone.entity.TWare;
import com.tmeone.erpone.entity.WareNoAndTime;
import com.tmeone.erpone.mapper.TWareMapper;
import com.tmeone.erpone.service.ITWareService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class TWareServiceImpl extends ServiceImpl<TWareMapper, TWare> implements ITWareService {

    @Autowired
    private TWareMapper wareMapper;

    @Override
    public IPage<TWare> warePage(IPage<TWare> page, WareNoAndTime wareNoAndTime) {
        IPage<TWare> tWareIPage = wareMapper.warePage(page,wareNoAndTime);
        tWareIPage.getRecords().forEach(TWare->{
            String wareNo = TWare.getWareNo();
            TWare.setShelveNum(wareMapper.selectShelveNumByWareId(wareNo));
            TWare.setCgoNum(wareMapper.selectCgoNumByWareId(wareNo));
            TWare.setEmptyCargoNum(wareMapper.selectEmptyCargoNumByWareId(wareNo));
        });
        return tWareIPage;
    }

    @Override
    public void updateWareStatusById(String wareId, String status) {
        wareMapper.updateWareStatusById(wareId,status);
    }



    @Override
    public IPage<TWare> selectWareCargoPageById(IPage<TWare> page, String id) {
        return wareMapper.selectWareCargoPageById(page,id);
    }

    @Override
    public List<TWare> selectWareCargo() {
        return wareMapper.selectWareCargo();
    }

    @Override
    public TWare selectTwareShelvesOne(String sId, String goodsName) {
        return wareMapper.selectTwareShelvesOne(sId,goodsName);
    }

    @Override
    public List<TWare> selectShelvesByAll1(String shelvesNo) {
        return wareMapper.selectShelvesByAll1(shelvesNo);
    }


}


